/*
 * Copyright 2013-2015 the original author or authors.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.xdtech.sys.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.xdtech.core.orm.utils.BeanUtils;
import com.xdtech.sys.model.FilterGroup;

/**
 * 
 * @author max.zheng
 * @create 2015-3-22下午7:00:18
 * @since 1.0
 * @see
 */
public class FilterGroupItem implements Serializable{
	private static final long serialVersionUID = -4616964188179102538L;

	private String option;
	
	private List<FilterRuleItem> rules = new ArrayList<FilterRuleItem>();

	public String getOption() {
		return option;
	}

	public void setOption(String option) {
		this.option = option;
	}

	public List<FilterRuleItem> getRules() {
		return rules;
	}

	public void setRules(List<FilterRuleItem> rules) {
		this.rules = rules;
	}
	/**
	 * 根据model构建vo
	 * 
	 * @author max
	 * @return
	 */
	public static FilterGroupItem createItem(FilterGroup filterGroup) {
		FilterGroupItem filterGroupItem = new FilterGroupItem();
		BeanUtils.copyProperties(filterGroupItem, filterGroup);
		//自定义属性设置填充
		return filterGroupItem;
	}
	/**
	 * 根据model集合创建vo集合
	 * 
	 * @author max
	 * @return
	 */
	public static List<FilterGroupItem> createItems(List<FilterGroup> filterGroups) {
		List<FilterGroupItem> filterGroupItems = new ArrayList<FilterGroupItem>();
		for (FilterGroup filterGroup : filterGroups) {
			filterGroupItems.add(createItem(filterGroup));
		}
		return filterGroupItems;
	}
	
}
